Color TAG IN HTML

Colors in HTML are integral for visual presentation and are defined primarily through CSS . CSS properties like color dictate the color of text, backgrounds, and borders on webpages. Colors can be specified using keywords (e.g., "red"), hexadecimal codes (e.g., #RRGGBB), RGB values (e.g., rgb(255, 0, 0)), or HSL values (e.g., hsl(0, 100%, 50%)). While HTML structures content, CSS styles it, allowing designers to create visually appealing websites. Mastery of color manipulation is crucial for web developers to ensure aesthetic coherence and accessibility across different devices and platforms.


  • Example of Color Tag :
  • Text Color Example:
  • 1.Color name:HTML supports a set of predefined color names like "red", "blue", "green", etc.

    <!DOCTYPE html> <html> <head> <title></title> </head> <body> <h4 style="color:red">PBA INSTITUTE.</h4> </body> </html>

    Output :

    PBA INSTITUTE.

    2. RGB Values: These are specified using the 'rgb()' function followed by the intensity of red, green, and blue. Each intensity value is between 0 and 255.

    <!DOCTYPE html> <html> <body> <h4 style="color: rgb(36, 51, 234 );">PBA INSTITUTE.</h4> </body> </html>

    Output :

    PBA INSTITUTE.


    3. Hexadecimal Color Codes:These are six-digit codes representing the intensity of red, green, and blue light in that color.

    <!DOCTYPE html> <html> <body> <h4 style="color: #EA24E1 ;">PBA INSTITUTE.</h4> </body> </html>

    Output :

    PBA INSTITUTE.

    4. HSL Values: These are specified using the hsl() function followed by the hue, saturation, and lightness. Hue is an angle between 0 and 360, and saturation and lightness are percentages.

    <!DOCTYPE html> <html> <body> <h4 style="color: hsl(126, 72%, 23%);">PBA INSTITUTE</h4> </body> </html>

    Output :

    PBA INSTITUTE

  • Backgroud color Example:
  • <!DOCTYPE html> <html> <body bgcolor="grey"> <h4 style="background-color: tomato">PBA INSTITUTE</h4> <address style="background-color: lightblue"> Address: 54/2/4/1, Danesh Shaikh Ln <br> B Shalimar Area, Shalimar, Howrah<br> West Bengal 711103<br> Phone:92394 12412 </address> </body> </html>

    Output:

    PBA INSTITUTE

    Address: 54/2/4/1, Danesh Shaikh Ln
    B Shalimar Area, Shalimar, Howrah
    West Bengal 711103
    Phone:92394 12412
  • Conclusion :
  • In conclusion, the versatility of color in HTML extends beyond mere aesthetics, playing a crucial role in user experience, branding, and accessibility. By understanding color theory and utilizing the wide spectrum of options available, developers can create visually appealing and functional websites that engage users effectively. Whether conveying emotion, guiding navigation, or establishing identity, the strategic use of color enhances the overall impact and usability of web design, fostering memorable and engaging online experiences.